import java.util.ArrayList;


public class Extrapolation {				
	
	/* TEMP, DEWP, STP, SLP, VISIB, 
	 * WDSP, PRCP, SNDP, CLDC, WNDDIR */

	private ArrayList<Double> TEMP;
	private ArrayList<Double> DEWP;
	private ArrayList<Double> STP;
	private ArrayList<Double> SLP;
	private ArrayList<Double> VISIB;
	private ArrayList<Double> WDSP;
	private ArrayList<Double> PRCP;
	private ArrayList<Double> SNDP;
	private ArrayList<Double> CLDC;
	private ArrayList<Integer> WNDDIR;

	
	public Double CLDCGrowth() {
		Double positives = 0.0;
		Double totalDifference = 0.0;
		Double last = Double.MIN_VALUE;		
		
		for (Double i : CLDC) {
			if (last.equals(Double.MIN_VALUE)) {
				last = i;
			} else {
				if (i > last)
					positives++;
				totalDifference += Math.abs(i - last);
				last = i;
			}
		}
		return ( positives >= ( CLDC.size() / 2 ) ) ?
				(totalDifference / CLDC.size()) : 
					0 - (totalDifference / CLDC.size());   
	}

	
	public Integer WNDDIRGrowth() {
		Integer positives = 0;
		Integer totalDifference = 0;
		Integer last = -1;
		
		
		for (Integer i : WNDDIR) {
			if (last.equals(-1)) {
				last = i;
			} else {
				if (i > last)
					positives++;
				totalDifference += Math.abs(i - last);
				last = i;
			}
		}
		return ( positives >= ( WNDDIR.size() / 2 ) ) ?
				(totalDifference / WNDDIR.size()) : 
					0 - (totalDifference / WNDDIR.size());   
	}
	
	
	
	/*
	 * Methods for adding information for Extrapolation
	 * 
	 */
	
	public void addTEMP(double arg0) {
		TEMP.add(arg0);
		while(TEMP.size() > 30)
			TEMP.remove(0);
	}
	
	public void addDEWP(double arg0) {
		DEWP.add(arg0);
		while(DEWP.size() > 30)
			DEWP.remove(0);		
	}
	
	public void addSTP(double arg0) {
		STP.add(arg0);
		while(STP.size() > 30)
			STP.remove(0);
	}
	
	public void addSLP(double arg0) {
		SLP.add(arg0);
		while(SLP.size() > 30)
			SLP.remove(0);
	}
	
	public void addVISIB(double arg0) {
		VISIB.add(arg0);
		while(VISIB.size() > 30)
			VISIB.remove(0);
	}
	
	public void addWDSP(double arg0) {
		WDSP.add(arg0);
		while(WDSP.size() > 30)
			WDSP.remove(0);
	}
	
	public void addPRCP(double arg0) {
		PRCP.add(arg0);
		while(PRCP.size() > 30)
			PRCP.remove(0);
	}
	
	public void addSNDP(double arg0) {
		SNDP.add(arg0);
		while(SNDP.size() > 30)
			SNDP.remove(0);
	}
	
	public void addCLDC(double arg0) {
		CLDC.add(arg0);
		while(CLDC.size() > 30)
			CLDC.remove(0);
	}
	
	public void addWNDDIR(int arg0) {
		WNDDIR.add(arg0);
		while(WNDDIR.size() > 30)
			WNDDIR.remove(0);
	}
}
